package main

import (
	"ManageServer/conf"
	"ManageServer/defs/dbs"
	"ManageServer/routers"
	"os"
)

func main() {
	// 环境获取
	conf.GetEnv()

	// 启动参数获取
	args := os.Args
	var env = "prod"
	if len(args) == 2 && args[1] != "" {
		env = args[1]
	}

	// 配置文件获取
	err := conf.CheckConf(env)
	if err != nil {
		return
	}
	err = conf.GetConf()
	if err != nil {
		return
	}
	// 初始化日志
	err = conf.InitLog()
	if err != nil {
		return
	}

	// 启动时就打开数据库连接
	dbs.InitSql()

	// 启动服务
	routers.Run()
}
